package com.db.cm.app.controller;


import com.db.cm.app.model.GoodsDO;
import com.db.cm.app.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author YOURSLIHUA
 * @since 2023-11-24
 */
@RestController
@RequestMapping("/goodsDO")
public class GoodsController {

    @Autowired
    GoodsService goodsService;

    @PostMapping("/add")
    public boolean add(@RequestParam GoodsDO goodsDO){
        return goodsService.add(goodsDO);
    }
    @PostMapping("/delete")
    public boolean deleteById(@RequestParam GoodsDO goodsDO) {

        return goodsService.delete(goodsDO);
    }

    @PostMapping("/update")
    public boolean update(@RequestParam GoodsDO goodsDO) {
        return  goodsService.delete(goodsDO);
    }
    @PostMapping("/selectAll")
    public List<GoodsDO> selectAll() {
        return goodsService.selectAll();
    }

    @PostMapping("/selectById")
    public GoodsDO selectById(@RequestParam GoodsDO goodsDO) {
        return goodsService.selectById(goodsDO.getGoodsId());
    }

}

